package com.hp.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.hp.ssm.entity.Hospital;
import com.hp.ssm.mapper.HospitalMapper;
import com.hp.ssm.service.HospitalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospitalServiceImpl implements HospitalService {
    @Autowired
    private HospitalMapper hospitalMapper;


    @Override
    public List<Hospital> findAll(Hospital hospital,Integer page,Integer limit) {
        // TODO Auto-generated method stub
        //使用PageHelper.startPage静态方法调用
        //startPage后面的第一个对数据库操作的方法，将自动进行分页，sql语句无需添加limit关键字
        if(page != null && limit != null) {
            PageHelper.startPage(page, limit);
        }
       //page为申请查询的页码，limit为一页显示多少条数据
        //userDao.findAll();//PageHelper.startPage()后面必须紧接查询数据的方法
        return hospitalMapper.findAll(hospital);
    }

    @Override
    public List<Hospital> deletefindAll(Hospital hospital,Integer page,Integer limit) {
        PageHelper.startPage(page, limit);
        return hospitalMapper.deletefindAll(hospital);
    }

    @Override
    public Hospital findById(Integer hid) {
        return hospitalMapper.findById(hid);
    }

    @Override
    public int recover(Hospital hospital) {
        return hospitalMapper.recover(hospital);
    }

    @Override
    public int update(Hospital hospital) {
        return hospitalMapper.update(hospital);
    }

    @Override
    public int add(Hospital hospital) {
        return hospitalMapper.add(hospital);
    }

    @Override
    public int delete(Integer hid) {
        return hospitalMapper.delete(hid);
    }


}
